package com.kanche.bigbaby.collection.domain;

import android.content.ContentValues;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.kanche.bigbaby.collection.DateUtils;
import com.kanche.bigbaby.collection.KKCheDBHelper;
import com.kanche.bigbaby.collection.StringUtils;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

//import com.kkche.bss.collection.KKCheDBHelper;
//import com.kkche.bss.domain.Merchant;
//import com.kkche.bss.domain.User;
//import com.kkche.bss.utils.DateUtils;
//import com.kkche.bss.utils.StringUtils;

//import com.kkche.bss.domain.User;
//import com.kkche.merchant.data.KKCheDBHelper;
//import com.kkche.merchant.utils.DateUtils;
//import com.kkche.merchant.utils.StringUtil;

/**
 * Created by nealmi on 6/9/14.
 */
public class Vehicle implements Serializable {
    public static final Vehicle NULL = new Vehicle();
    private transient long _id = 0L;
    private String id;//服务器端ID
    private Merchant merchant;


    private boolean substituted;
    private String merchantUserId = null; //#创建者id
    private String merchantId = null; //#商家id
    private String galleryId = null; //#相册id：可以为空
    private String vin = ""; //#车辆识别号-- 可选

    private Gallery gallery = new Gallery();

    //    private Model model = new Model();
    private Spec spec = new Spec();
    private Address address = new Address();
    private Location location = new Location();
    private Summary summary = new Summary();
    private VehicleDate vehicleDate = new VehicleDate();
    private Price price = new Price();
    private Status status = new Status();
    private List<Contact> contacts = new ArrayList<Contact>();
    private Desc desc = new Desc();
    private Document document = new Document();
    private String createAt = DateUtils.now();
    private String updateAt = DateUtils.now();
    private User user = new User();
    private List<DistributionJob> shareJobList;

    private String modifyFrom;

    public Vehicle() {
    }



    public Merchant getMerchant() {
        return merchant;
    }

    public void setMerchant(Merchant merchant) {
        this.merchant = merchant;
    }
    public String getModifyFrom() {
        return modifyFrom;
    }

    public void setModifyFrom(String modifyFrom) {
        this.modifyFrom = modifyFrom;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public String getCreateAt() {
        return createAt;
    }

    public void setCreateAt(String createAt) {
        this.createAt = createAt;
    }

    public String getUpdateAt() {
        return updateAt;
    }

    public void setUpdateAt(String updateAt) {
        this.updateAt = updateAt;
    }

    public boolean isIntegral() {
        boolean hasPhoto = StringUtils.hasText(gallery.getFirstAvailablePhotoPath());
//        boolean hasVin = StringUtil.hasText(vin);
        boolean hasLevelId = StringUtils.hasText(getSpec().getLevelId());
        boolean hasPrice = getPrice().getQuotedPrice() != 0L;
        boolean hasMileage = getSummary().getMileage() != 0L;
        boolean hasFullDesc = StringUtils.hasText(getDesc().getDetail());
        boolean hasRegistrationDate = StringUtils.hasText(getVehicleDate().getRegistrationDate());
        return hasPhoto && hasLevelId && hasPrice && hasMileage && hasRegistrationDate && hasFullDesc;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getVin() {
        return vin;
    }

    public void setVin(String vin) {
        this.vin = vin;
    }

    public String getMerchantUserId() {
        return merchantUserId;
    }

    public void setMerchantUserId(String merchantUserId) {
        this.merchantUserId = merchantUserId;
    }

    public String getMerchantId() {
        return merchantId;
    }

    public void setMerchantId(String merchantId) {
        this.merchantId = merchantId;
    }

    public String getGalleryId() {
        if (!StringUtils.hasText(galleryId) && gallery != null && StringUtils.hasText(gallery.getId())) {
            galleryId = gallery.getId();
        }
        return galleryId;
    }

    public void setGalleryId(String galleryId) {
        this.galleryId = galleryId;
    }

    public Spec getSpec() {
        return spec;
    }

    public void setSpec(Spec spec) {
        this.spec = spec;
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public Location getLocation() {
        return location;
    }

    public void setLocation(Location location) {
        this.location = location;
    }

    public Summary getSummary() {
        return summary;
    }

    public void setSummary(Summary summary) {
        this.summary = summary;
    }

    public VehicleDate getVehicleDate() {
        return vehicleDate;
    }

    public void setVehicleDate(VehicleDate vehicleDate) {
        this.vehicleDate = vehicleDate;
    }

    public Price getPrice() {
        return price;
    }

    public void setPrice(Price price) {
        this.price = price;
    }

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    public List<Contact> getContacts() {
        return contacts;
    }

    public void setContacts(List<Contact> contacts) {
        this.contacts = contacts;
    }

    public Desc getDesc() {
        return desc;
    }

    public void setDesc(Desc desc) {
        this.desc = desc;
    }

    public Document getDocument() {
        return document;
    }

    public void setDocument(Document document) {
        this.document = document;
    }

    public Gallery getGallery() {
        return gallery;
    }

    public void setGallery(Gallery gallery) {
        this.gallery = gallery;
    }

    public List<DistributionJob> getShareJobList() {
        return shareJobList;
    }

    public void setShareJobList(List<DistributionJob> shareJobList) {
        this.shareJobList = shareJobList;
    }

    public ContentValues toContentValues() {
        ContentValues values = new ContentValues();
        values.put(KKCheDBHelper.VehicleColumns.merchantUserId, merchantUserId);
        values.put(KKCheDBHelper.VehicleColumns.merchantId, merchantId);
        values.put(KKCheDBHelper.VehicleColumns.id, id);
        values.put(KKCheDBHelper.VehicleColumns.galleryId, getGalleryId());
        values.put(KKCheDBHelper.VehicleColumns.vin, getVin());
        values.put(KKCheDBHelper.VehicleColumns.createAt, getCreateAt());
        values.put(KKCheDBHelper.VehicleColumns.updateAt, getUpdateAt());
        values.put(KKCheDBHelper.VehicleColumns.modifyFrom, getModifyFrom());


        if (gallery != null) {
            values.putAll(gallery.toContentValues());
        }
        if (getSpec() != null) {
            values.putAll(getSpec().toContentValues());
        }
        if (price != null) {
            values.putAll(price.toContentValues());
        }
        if (summary != null) {
            values.putAll(summary.toContentValues());
        }
        if (document != null) {
            values.putAll(document.toContentValues());
        }
        if (status != null) {
            values.putAll(status.toContentValues());
        }
        if (address != null) {
            values.putAll(address.toContentValues());
        }
        if (location != null) {
            values.putAll(location.toContentValues());
        }
        if (vehicleDate != null) {
            values.putAll(vehicleDate.toContentValues());
        }
        if (desc != null) {
            values.putAll(desc.toContentValues());
        }
        return values;
    }

    public long get_id() {
        return _id;
    }

    public void set_id(long _id) {
        this._id = _id;
    }

    public void setContactsJson(String contactsJson) {
        Gson gson = new Gson();
        contacts = gson.fromJson(contactsJson, new TypeToken<List<Contact>>() {
        }.getType());
    }

    public String getContactsDisplay() {
        if (contacts != null && contacts.size() > 0) {
            StringBuilder builder = new StringBuilder();
            for (Contact contact : contacts) {
                builder.append(contact.getName()).append(" ").append(contact.getPhone()).append("\n");
            }
            builder.deleteCharAt(builder.length() - 1);
            return builder.toString();
        }
        if (user != null && StringUtils.hasText(user.getPublicPhone())) {
            StringBuilder builder = new StringBuilder();
            builder.append(user.getName() + "  " + user.getPublicPhone());
            return builder.toString();
        }
        return "";
    }

    public String getContactName() {
        if (user != null && StringUtils.hasText(user.getPublicPhone())) {
            return user.getName();
        }
        return "";
    }

    public String getContactMobile() {
        if (user != null && StringUtils.hasText(user.getPublicPhone())) {
            return user.getPublicPhone();
        }
        return "";
    }

    public void washDataForDearServer() {
        if (!StringUtils.hasText(getVin())) {
            setVin(null);
        }
    }

    public boolean isSubstituted() {
        return substituted;
    }

    public void setSubstituted(boolean substituted) {
        this.substituted = substituted;
    }


    public static class Model implements Serializable {
        //        private String vin = ""; //#车辆识别号-- 可选
        private String levelId = ""; //#车辆数据库唯一key--必填
        private String brand = ""; //#品牌
        private String yearGroup = ""; //#年份
        private String saleName = "";
        private String series = "";

        public Model() {
        }

//        public String getVin() {
//            return vin;
//        }
//
//        public void setVin(String vin) {
//            this.vin = vin;
//        }

        public String getLevelId() {
            return levelId;
        }

        public void setLevelId(String levelId) {
            this.levelId = levelId;
        }

        public String getBrand() {
            return brand;
        }

        public void setBrand(String brand) {
            this.brand = brand;
        }

        public String getYearGroup() {
            return yearGroup;
        }

        public void setYearGroup(String yearGroup) {
            this.yearGroup = yearGroup;
        }

        public String getSaleName() {
            return saleName;
        }

        public void setSaleName(String saleName) {
            this.saleName = saleName;
        }

        public String getSeries() {
            return series;
        }

        public void setSeries(String series) {
            this.series = series;
        }

        public ContentValues toContentValues() {
            ContentValues values = new ContentValues();
//            values.put(KKCheDBHelper.VehicleColumns.vin, getVin());
            values.put(KKCheDBHelper.VehicleColumns.levelId, getLevelId());
            values.put(KKCheDBHelper.VehicleColumns.brand, getBrand());
            values.put(KKCheDBHelper.VehicleColumns.yearGroup, getYearGroup());
            values.put(KKCheDBHelper.VehicleColumns.saleName, getSaleName());
            values.put(KKCheDBHelper.VehicleColumns.series, getSeries());
            return values;
        }

        public String getDisplayValue() {
            StringBuilder builder = new StringBuilder();
            if (StringUtils.hasText(brand))
                builder.append(brand).append(" - ");
            if (StringUtils.hasText(series))
                builder.append(series).append(" - ");
            if (StringUtils.hasText(yearGroup)) {
                builder.append(yearGroup).append("款 - ");
            }
            builder.append(saleName);
            return builder.toString();
        }

        public String getDisplayShort() {
            StringBuilder builder = new StringBuilder();
            if (StringUtils.hasText(brand))
                builder.append(brand).append(" - ");
            if (StringUtils.hasText(series))
                builder.append(series);
            return builder.toString();
        }
    }

    public static class Spec extends Model {

    }

    public static class Address implements Serializable {
        private String provinceCode = "";//#所属省份
        private String provinceName = "";//#所属省份
        private String cityCode = "";//#城市
        private String cityName = "";//#城市
        private String districtCode = "";//#区域
        private String districtName = "";//#区域
        private String detail = "";//#地址

        public String getProvinceCode() {
            return provinceCode;
        }

        public void setProvinceCode(String provinceCode) {
            this.provinceCode = provinceCode;
        }

        public String getCityCode() {
            return cityCode;
        }

        public void setCityCode(String cityCode) {
            this.cityCode = cityCode;
        }

        public String getDistrictCode() {
            return districtCode;
        }

        public void setDistrictCode(String districtCode) {
            this.districtCode = districtCode;
        }

        public String getDetail() {
            return detail;
        }

        public void setDetail(String detail) {
            this.detail = detail;
        }

        public String getProvinceName() {
            return provinceName;
        }

        public void setProvinceName(String provinceName) {
            this.provinceName = provinceName;
        }

        public String getCityName() {
            return cityName;
        }

        public void setCityName(String cityName) {
            this.cityName = cityName;
        }

        public String getDistrictName() {
            return districtName;
        }

        public void setDistrictName(String districtName) {
            this.districtName = districtName;
        }

        public ContentValues toContentValues() {
            ContentValues values = new ContentValues();
            values.put(KKCheDBHelper.VehicleColumns.provinceCode, provinceCode);
            values.put(KKCheDBHelper.VehicleColumns.cityCode, cityCode);
            values.put(KKCheDBHelper.VehicleColumns.districtCode, districtCode);
            values.put(KKCheDBHelper.VehicleColumns.detail, detail);
            return values;
        }

        public String getFullAddress() {
            StringBuilder builder = new StringBuilder()
                    .append(provinceName)
                    .append(cityName)
                    .append(districtName);
            if (StringUtils.hasText(detail)) {
                builder.append(detail);
            }
            return builder.toString();
        }

        public String getAreaAddress() {
            StringBuilder builder = new StringBuilder()
                    .append(provinceName)
                    .append(cityName);
            return builder.toString();
        }
    }

    public static class Location implements Serializable {
        private float lat = 0f;// # 纬度 浮点数
        private float lng = 0f; //#经度 浮点数

        public float getLat() {
            return lat;
        }

        public void setLat(float lat) {
            this.lat = lat;
        }

        public float getLng() {
            return lng;
        }

        public void setLng(float lng) {
            this.lng = lng;
        }

        public ContentValues toContentValues() {
            ContentValues values = new ContentValues();
            values.put(KKCheDBHelper.VehicleColumns.lat, lat);
            values.put(KKCheDBHelper.VehicleColumns.lng, lng);
            return values;
        }
    }

    public static class Summary implements Serializable {
        private String licenseNumber = ""; //#车牌号 -- 可选
        private String color = ""; //#颜色 -- 可选
        private int mileage = 0; //#里程（公里数）-- Int类型，可选
        private int tradeTimes = 0;// #过户次数 -- Int类型，可选
        private String purpose = ""; //#车辆用途，可以是（business, personal, lease）之一
        private String emissionStandard = ""; // #排放标准，可以是（国一，国二，国三，国四，国五）之一
        private boolean accident = false;// #事故历史，Boolean
        private boolean maintenance = true; //#定期维护，Boolean
        private String interior; //#内饰颜色，light or dark
        private String drivingLicensePicture;//行驶证
        private boolean consignment = false;//默认自有车源

        public boolean isConsignment() {
            return consignment;
        }

        public void setConsignment(boolean consignment) {
            this.consignment = consignment;
        }

        public String getDrivingLicensePicture() {
            return drivingLicensePicture;
        }

        public void setDrivingLicensePicture(String drivingLicensePicture) {
            this.drivingLicensePicture = drivingLicensePicture;
        }

        public String getLicenseNumber() {
            return licenseNumber;
        }

        public void setLicenseNumber(String licenseNumber) {
            this.licenseNumber = licenseNumber;
        }

        public String getColor() {
            return color;
        }

        public void setColor(String color) {
            this.color = color;
        }

        public int getMileage() {
            return mileage;
        }

        public void setMileage(int mileage) {
            this.mileage = mileage;
        }

        public String getMileageByTenKm() {
            if (mileage == 0) {
                return "";
            } else {
                return new BigDecimal(mileage)
                        .divide(new BigDecimal(10000))
                        .setScale(2, BigDecimal.ROUND_FLOOR)
                        .toString();
            }
        }

        public void setMileageByTenKm(String value) {
            if (StringUtils.hasText(value)) {
                mileage = new BigDecimal(value)
                        .multiply(new BigDecimal(10000))
                        .toBigInteger().intValue();
            } else {
                mileage = 0;
            }
        }

        public int getTradeTimes() {
            return tradeTimes;
        }

        public void setTradeTimes(int tradeTimes) {
            this.tradeTimes = tradeTimes;
        }

        public String getPurpose() {
            return purpose;
        }

        public void setPurpose(String purpose) {
            this.purpose = purpose;
        }

        public String getEmissionStandard() {
            return emissionStandard;
        }

        public void setEmissionStandard(String emissionStandard) {
            this.emissionStandard = emissionStandard;
        }

        public boolean isAccident() {
            return accident;
        }

        public void setAccident(boolean accident) {
            this.accident = accident;
        }

        public boolean isMaintenance() {
            return maintenance;
        }

        public void setMaintenance(boolean maintenance) {
            this.maintenance = maintenance;
        }

        public String getInterior() {
            return interior;
        }

        public void setInterior(String interior) {
            this.interior = interior;
        }

        public ContentValues toContentValues() {
            ContentValues values = new ContentValues();
            values.put(KKCheDBHelper.VehicleColumns.licenseNumber, licenseNumber);
            values.put(KKCheDBHelper.VehicleColumns.color, color);
            values.put(KKCheDBHelper.VehicleColumns.mileage, mileage);
            values.put(KKCheDBHelper.VehicleColumns.tradeTimes, tradeTimes);
            values.put(KKCheDBHelper.VehicleColumns.purpose, purpose);
            values.put(KKCheDBHelper.VehicleColumns.emissionStandard, emissionStandard);
            values.put(KKCheDBHelper.VehicleColumns.accident, StringUtils.boolToInt(accident));
            values.put(KKCheDBHelper.VehicleColumns.maintenance, StringUtils.boolToInt(maintenance));
            values.put(KKCheDBHelper.VehicleColumns.interior, interior);
            values.put(KKCheDBHelper.VehicleColumns.drivingLicensePicture,drivingLicensePicture);
            values.put(KKCheDBHelper.VehicleColumns.consignment,StringUtils.boolToInt(consignment));
            return values;
        }
    }

    public static class VehicleDate implements Serializable {
        private String registrationDate;// #初登日期 -- 可选
        private String inspectionDate;// #验车日期 -- 可选
        private String commercialInsuranceExpireDate;// #商业险到期时间 -- 可选
        private String compulsoryInsuranceExpireDate; // #交强险到期时间 -- 可选
        private String manufactureDate;//出厂日期

        public String getManufactureDate() {
            return manufactureDate;
        }

        public void setManufactureDate(String manufactureDate) {
            this.manufactureDate = manufactureDate;
        }

        public String getRegistrationDate() {
            return registrationDate;
        }

        public void setRegistrationDate(String registrationDate) {
            this.registrationDate = registrationDate;
        }

        public String getInspectionDate() {
            return inspectionDate;
        }

        public void setInspectionDate(String inspectionDate) {
            this.inspectionDate = inspectionDate;
        }

        public String getCommercialInsuranceExpireDate() {
            return commercialInsuranceExpireDate;
        }

        public void setCommercialInsuranceExpireDate(String commercialInsuranceExpireDate) {
            this.commercialInsuranceExpireDate = commercialInsuranceExpireDate;
        }

        public String getCompulsoryInsuranceExpireDate() {
            return compulsoryInsuranceExpireDate;
        }

        public void setCompulsoryInsuranceExpireDate(String compulsoryInsuranceExpireDate) {
            this.compulsoryInsuranceExpireDate = compulsoryInsuranceExpireDate;
        }

        public ContentValues toContentValues() {
            ContentValues values = new ContentValues();
            values.put(KKCheDBHelper.VehicleColumns.registrationDate, registrationDate);
            values.put(KKCheDBHelper.VehicleColumns.inspectionDate, inspectionDate);
            values.put(KKCheDBHelper.VehicleColumns.commercialInsuranceExpireDate, commercialInsuranceExpireDate);
            values.put(KKCheDBHelper.VehicleColumns.alcInsuranceExpireDate, compulsoryInsuranceExpireDate);
            values.put(KKCheDBHelper.VehicleColumns.manufactureDate, manufactureDate);

            return values;
        }
    }

    public static class Price implements Serializable {
        private int quotedPrice = 0;// #报价 -- Int类型，精确到元。可选
        private int bidPrice = 0;// #采购价格 -- Int类型，精确到元。可选
        private int offerPrice = 0;// #卖出价格 Int类型，精确到元。（可以为空，在修改状态为sold的时候加上）-- 可选
        private boolean quotedPriceIncludeTransferFee = true;

        public int getQuotedPrice() {
            return quotedPrice;
        }

        public void setQuotedPrice(int quotedPrice) {
            this.quotedPrice = quotedPrice;
        }

        public int getBidPrice() {
            return bidPrice;
        }

        public void setBidPrice(int bidPrice) {
            this.bidPrice = bidPrice;
        }

        public int getOfferPrice() {
            return offerPrice;
        }

        public void setOfferPrice(int offerPrice) {
            this.offerPrice = offerPrice;
        }

        public boolean isQuotedPriceIncludeTransferFee() {
            return quotedPriceIncludeTransferFee;
        }

        public void setQuotedPriceIncludeTransferFee(boolean quotedPriceIncludeTransferFee) {
            this.quotedPriceIncludeTransferFee = quotedPriceIncludeTransferFee;
        }

        public String getQuotedPriceByTenGrand() {
            if (quotedPrice == 0) {
                return "";
            } else {
                return new BigDecimal(quotedPrice).divide(new BigDecimal(10000)).setScale(2, BigDecimal.ROUND_FLOOR).toString();
            }
        }

        public void setQuotedPriceByTenGrand(String value) {
            if (StringUtils.hasText(value)) {
                quotedPrice = new BigDecimal(value)
                        .multiply(new BigDecimal(10000))
                        .toBigInteger().intValue();
            } else {
                quotedPrice = 0;
            }
        }


        public String getBidPriceByTenGrand() {
            if (bidPrice == 0) {
                return "";
            } else {
                return new BigDecimal(bidPrice).divide(new BigDecimal(10000)).setScale(2, BigDecimal.ROUND_FLOOR).toString();
            }
        }

        public void setBidPriceByTenGrand(String value) {
            if (StringUtils.hasText(value)) {
                bidPrice = new BigDecimal(value)
                        .multiply(new BigDecimal(10000))
                        .toBigInteger().intValue();
            } else {
                bidPrice = 0;
            }
        }

        public String getOfferPriceByTenGrand() {
            if (offerPrice == 0) {
                return "";
            } else {
                return new BigDecimal(offerPrice).divide(new BigDecimal(10000)).setScale(2, BigDecimal.ROUND_FLOOR).toString();
            }
        }

        public void setOfferPriceByTenGrand(String value) {
            if (StringUtils.hasText(value)) {
                offerPrice = new BigDecimal(value)
                        .multiply(new BigDecimal(10000))
                        .toBigInteger().intValue();
            } else {
                offerPrice = 0;
            }
        }

        public ContentValues toContentValues() {
            ContentValues values = new ContentValues();
            values.put(KKCheDBHelper.VehicleColumns.quotedPrice, quotedPrice);
            values.put(KKCheDBHelper.VehicleColumns.bidPrice, bidPrice);
            values.put(KKCheDBHelper.VehicleColumns.offerPrice, offerPrice);
            values.put(KKCheDBHelper.VehicleColumns.quotedPriceIncludeTransferFee, StringUtils.boolToInt(quotedPriceIncludeTransferFee));
            return values;
        }
    }

    public static class Status implements Serializable {
        private boolean offline = false;//#是否下线，Boolean类型，false为在线上，true为已下架
        private boolean sold = false;//#是否售出，true为售出。（该状态由前端维护，逻辑如下：如果offline为true，并且bidPrice和offerPrice都存在并且不为0，则saled=true）
        private boolean draft = false;// #是否为草稿，Boolean类型

        private boolean reject;
        private String rejectReason;
        private String rejectComment;

        public boolean isReject() {
            return reject;
        }

        public void setReject(boolean reject) {
            this.reject = reject;
        }

        public String getRejectReason() {
            return rejectReason;
        }

        public void setRejectReason(String rejectReason) {
            this.rejectReason = rejectReason;
        }

        public String getRejectComment() {
            return rejectComment;
        }

        public void setRejectComment(String rejectComment) {
            this.rejectComment = rejectComment;
        }

        public boolean isOffline() {
            return offline;
        }

        public void setOffline(boolean offline) {
            this.offline = offline;
        }

        public boolean isSold() {
            return sold;
        }

        public void setSold(boolean sold) {
            this.sold = sold;
        }

        public boolean isDraft() {
            return draft;
        }

        public void setDraft(boolean draft) {
            this.draft = draft;
        }

        public ContentValues toContentValues() {
            ContentValues values = new ContentValues();
            values.put(KKCheDBHelper.VehicleColumns.offline, StringUtils.boolToInt(offline));
            values.put(KKCheDBHelper.VehicleColumns.sold, StringUtils.boolToInt(sold));
            values.put(KKCheDBHelper.VehicleColumns.draft, StringUtils.boolToInt(draft));
            values.put(KKCheDBHelper.VehicleColumns.reject, StringUtils.boolToInt(reject));
            values.put(KKCheDBHelper.VehicleColumns.rejectComment, rejectComment);
            values.put(KKCheDBHelper.VehicleColumns.rejectReason, rejectReason);
            return values;
        }
    }

    public static class Contact implements Serializable {
        private String name = ""; //#联系人
        private String phone = ""; //#电话，数组，不限长度

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getPhone() {
            return phone;
        }

        public void setPhone(String phone) {
            this.phone = phone;
        }

        @Override
        public String toString() {
            return super.toString();
        }
    }

    public static class Desc implements Serializable {
        private String brief = ""; // #短描述
        private String detail = ""; //#说明
        private List<VehicleDescIndividual> individualList;
        private List<VehicleDescHighlight> highlightList;

        public static List<VehicleDescIndividual> fromJson(String json) {
            Gson gson = new Gson();
            List<VehicleDescIndividual> individualList = gson.fromJson(json, new TypeToken<List<VehicleDescIndividual>>() {
            }.getType());
            if (individualList == null) {
                individualList = new ArrayList<VehicleDescIndividual>();
            }

            return individualList;
        }

        public static List<VehicleDescHighlight> fromHighlightJson(String json) {
            Gson gson = new Gson();
            List<VehicleDescHighlight> highlightList = gson.fromJson(json, new TypeToken<List<VehicleDescHighlight>>() {
            }.getType());
            if (highlightList == null) {
                highlightList = new ArrayList<VehicleDescHighlight>();
            }
            return highlightList;
        }

        public List<VehicleDescIndividual> getIndividualList() {
            if (individualList == null) {
                individualList = new ArrayList<VehicleDescIndividual>();
            }
            return individualList;
        }

        public List<VehicleDescHighlight> getHighlightList() {
            if (highlightList == null) {
                highlightList = new ArrayList<VehicleDescHighlight>();
            }
            return highlightList;
        }

        public void setIndividualList(List<VehicleDescIndividual> individualList) {
            this.individualList = individualList;
        }

        public void setHighlightList(List<VehicleDescHighlight> highlightList) {
            this.highlightList = highlightList;
        }

        public String getBrief() {
            return brief;
        }

        public void setBrief(String brief) {
            this.brief = brief;
        }

        public String getDetail() {
            return detail;
        }

        public void setDetail(String detail) {
            this.detail = detail;
        }

        public ContentValues toContentValues() {
            Gson gson = new Gson();
            ContentValues values = new ContentValues();
            values.put(KKCheDBHelper.VehicleColumns.briefDesc, brief);
            values.put(KKCheDBHelper.VehicleColumns.fullDesc, detail);
            values.put(KKCheDBHelper.VehicleColumns.individualList, gson.toJson(individualList));
            values.put(KKCheDBHelper.VehicleColumns.highlightList, gson.toJson(highlightList));
            return values;
        }
    }

    public static class Document implements Serializable {
        private boolean property = true;// #(产权证）Boolean类型
        private boolean instructions = true;// #(说明书） Boolean类型
        private boolean transferTicket = true;// #(过户票) Boolean类型
        private boolean roadMaintenance = true;// #（养路费）Boolean类型
        private boolean carTax = true;// #（车船税）Boolean类型
        private boolean maintenanceManual = true;// #（保养手册）Boolean类型
        private boolean purchaseTax = true;// #（购置税）Boolean类型
        private boolean registrationCertificate = true;// #（登记证）Boolean类型

        public ContentValues toContentValues() {
            ContentValues values = new ContentValues();
            values.put(KKCheDBHelper.VehicleColumns.propertyDoc, StringUtils.boolToInt(property));
            values.put(KKCheDBHelper.VehicleColumns.instructionsDoc, StringUtils.boolToInt(instructions));
            values.put(KKCheDBHelper.VehicleColumns.transferTicketDoc, StringUtils.boolToInt(transferTicket));
            values.put(KKCheDBHelper.VehicleColumns.roadMaintenanceDoc, StringUtils.boolToInt(roadMaintenance));
            values.put(KKCheDBHelper.VehicleColumns.carTaxDoc, StringUtils.boolToInt(carTax));
            values.put(KKCheDBHelper.VehicleColumns.maintenanceManualDoc, StringUtils.boolToInt(maintenanceManual));
            values.put(KKCheDBHelper.VehicleColumns.purchaseTaxDoc, StringUtils.boolToInt(purchaseTax));
            values.put(KKCheDBHelper.VehicleColumns.registrationCertDoc, StringUtils.boolToInt(registrationCertificate));
            return values;
        }

        public boolean isProperty() {
            return property;
        }

        public void setProperty(boolean property) {
            this.property = property;
        }

        public boolean isInstructions() {
            return instructions;
        }

        public void setInstructions(boolean instructions) {
            this.instructions = instructions;
        }

        public boolean isTransferTicket() {
            return transferTicket;
        }

        public void setTransferTicket(boolean transferTicket) {
            this.transferTicket = transferTicket;
        }

        public boolean isRoadMaintenance() {
            return roadMaintenance;
        }

        public void setRoadMaintenance(boolean roadMaintenance) {
            this.roadMaintenance = roadMaintenance;
        }

        public boolean isCarTax() {
            return carTax;
        }

        public void setCarTax(boolean carTax) {
            this.carTax = carTax;
        }

        public boolean isMaintenanceManual() {
            return maintenanceManual;
        }

        public void setMaintenanceManual(boolean maintenanceManual) {
            this.maintenanceManual = maintenanceManual;
        }

        public boolean isPurchaseTax() {
            return purchaseTax;
        }

        public void setPurchaseTax(boolean purchaseTax) {
            this.purchaseTax = purchaseTax;
        }

        public boolean isRegistrationCertificate() {
            return registrationCertificate;
        }

        public void setRegistrationCertificate(boolean registrationCertificate) {
            this.registrationCertificate = registrationCertificate;
        }


    }
}
